/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package orchestrarehearsal;

import ilog.concert.IloException;
import ilog.concert.IloIntVar;
import ilog.cp.cppimpl.IloCP;
import ilog.cplex.IloCplex;
import java.util.logging.Level;
import java.util.logging.Logger;





/**
 *
 * @author Guillaume
 */
public class OrchestraRehearsal {
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Data dat = new Data();
        
        try {
            IloCplex cplex = new IloCplex();
            LinearModelCplex model = new LinearModelCplex();
            
            model.createModel(cplex, dat);
            System.out.println(cplex.solve() + "\nFIN CPLEX SOLVE"); // solve renvoie true si cplex a trouvé une solution
            System.out.println(cplex.getStatus() + "\nFIN GETSTATUS");
            System.out.println(cplex.getCplexStatus() + "\nFIN CPLEX GETSTATUS");
            System.out.println(cplex.getObjValue());
            
            for (int i = 0; i < model.getX().getSize(); i++) {
                IloIntVar x = model.getX().getIntVar(i);
                System.out.println("x" + i + " = " + cplex.getValue(x));
            }
            
        } catch (IloException ex) {
            Logger.getLogger(OrchestraRehearsal.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        System.out.println("HHHHHHHHHHHHHHHHHHHHHHHHHHHHH");
        System.out.println("HHHHHHHHHHHHHHHHHHHHHHHHHHHHH");
        System.out.println("HHHHHHHHHHHHHHHHHHHHHHHHHHHHH");
        System.out.println("HHHHHHHHHHHHHHHHHHHHHHHHHHHHH");
        
        try {
            IloCP cp = new IloCP();
            LinearModelCP model = new LinearModelCP(cp);
            
            model.createModel(cp, dat);
            System.out.println(cp.solve() + "\nFIN CPLEX SOLVE"); // solve renvoie true si cplex a trouvé une solution
            System.out.println(cp.getStatus() + "\nFIN GETSTATUS");
            System.out.println(cp.getObjValue());
            
            for (int i = 0; i < model.getX().getSize(); i++) {
                ilog.concert.IloIntVar x = model.getX().getIntVar(i);
                System.out.println("x" + i + " = " + cp.getValue(x));
            }
            
        } catch (IloException ex) {
            Logger.getLogger(OrchestraRehearsal.class.getName()).log(Level.SEVERE, null, ex);
        }
        
    }
    
}
